<template>
	<div class="myhome">
		<template>
			<el-table class="table" :data="tableData" style="width: 100%">
				<el-table-column prop="outletLogo" label="头像">
					<template slot-scope="scope">
						<!-- {{scope.row.outletLogo}} -->
						<img :src="baseUrl+scope.row.outletLogo" alt="" />
					</template>
				</el-table-column>
				<el-table-column prop="outletName" label="门店名">
				</el-table-column>
				<el-table-column prop="adminAccount" label="账号">
				</el-table-column>
				<el-table-column label="操作">
					<template slot-scope="scope">
						<!-- {{scope.row.outletId}} -->
						<el-button type="primary" @click="changeMine(scope.row.outletId)">修改</el-button>
						<el-button type="info" @click="gomore(scope.row.outletId)">更多</el-button>
					</template>
					
				</el-table-column>
			</el-table>
		</template>
		<!-- 分页 -->
		<el-pagination class="page" :page-size="pageSize" layout="prev, pager, next" @current-change="changepage"
			:total="total" style="text-align: center;margin-top: 30px;">
		</el-pagination>
	</div>
</template>

<script>
	import {
		baseUrl
	} from '../assets/baseUrl.js'
	export default {
		data() {
			return {
				baseUrl: require('../assets/baseUrl.js').baseUrl,
				pageIndex:"1",
				pageSize:5,
				total:0,
				adminId: "",
				tableData: [{}],
				
			}
		},
		methods: {
			changepage(page) {
				// 分页器
				this.pageIndex = page
				this.getAllOutletsAdmin()
			},
			gomore(outletId) {
				this.$router.push("/homepage/minemore?outletId="+outletId)
			},
			changeMine(outletId) {
				this.$router.push("/homepage/mineedit?outletId="+outletId)
			},
			// http://localhost:8081/outlets/outlet/getAllOutletsByAdminId
			getAllOutletsAdmin() {
				this.$http.post(baseUrl + "outlets/outlet/getAllOutletsByAdminId", {
					adminId: Number(this.adminId),
					page:Number(this.pageIndex),
					size:Number(this.pageSize)
				}).then(res => {
					// console.log(res.data.data)
					if(res.data.code==200){
						this.total=res.data.data.totalPages*this.pageSize
						this.tableData=res.data.data.outlets
					}
					
					
				})
			}
		},
		mounted() {
			this.tableData[0].adminName = sessionStorage.getItem("adminName")
			this.tableData[0].iserIcon = sessionStorage.getItem("iserIcon")
			this.tableData[0].username = sessionStorage.getItem("username")
			this.adminId = sessionStorage.getItem("adminId")
			this.getAllOutletsAdmin()
		}
	}
</script>

<style>
	/* 表格 */
	.myhome .el-table .el-table__cell {
		text-align: center;
	}

	.myhome .table img {
		width: 60px;
		height: 60px;
		border-radius: 50px;
	}
</style>